package com.guigu.handler.impl;

import cn.hutool.core.bean.BeanUtil;
import com.guigu.annotation.SubjectInfoType;
import com.guigu.domain.dto.SubjectInfoDTO;
import com.guigu.domain.entity.SubjectBrief;
import com.guigu.domain.enums.IsDeletedFlagEnum;
import com.guigu.domain.enums.SubjectInfoEnum;
import com.guigu.handler.SubjectInfoHandler;
import com.guigu.service.ISubjectBriefService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @description: 简答题
 * @author: JZC
 * @create: 2024-06-07 00:21
 **/
@Component("briefTypeSubjectInfoHandler")
@SubjectInfoType(type = SubjectInfoEnum.BRIEF_TYPE)
@Slf4j
public class BriefTypeSubjectInfoHandler implements SubjectInfoHandler {
    @Resource
    private ISubjectBriefService subjectBriefService;
    @Override
    public void add(SubjectInfoDTO subjectInfoDTO) {
        log.info("简答题添加逻辑代码...");
        SubjectBrief subjectBrief = BeanUtil.toBean(subjectInfoDTO, SubjectBrief.class);
        subjectBrief.setSubjectId(subjectInfoDTO.getId());
        subjectBrief.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
        subjectBriefService.save(subjectBrief);
    }
}
